import {acceptHMRUpdate, defineStore} from "pinia";
import {ref} from "vue";

export const useTaskListStore = defineStore('taskList', () => {
  const taskList = ref([]);
  const dialogVisible = ref([]);
  const interval = ref(0);

  const cover = (list) => {
    taskList.value = list
    dialogVisible.value = taskList.value.map(() => false)
  }

  // 打开弹窗
  const openDialog = (index, taskInterval) => {
    dialogVisible.value[index] = true
    interval.value = taskInterval
  }

  // 关闭弹窗
  const closeDialog = (index) => {
    dialogVisible.value[index] = false
  }

  return {
    taskList,
    dialogVisible,
    interval,
    cover,
    openDialog,
    closeDialog,
  }
})

if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(useTaskListStore, import.meta.hot))
}